#include<iostream>
#include<string>
#include<cstdio>
#include<mysql.h>

const std::string host = "127.0.0.1";
const std::string user = "hjh";
const std::string password = "hu20050610";
const std::string db = "2025_06_29";
unsigned int port = 3306;

int main()
{
    MYSQL * sql =nullptr;
    sql = mysql_init(sql);

    if(sql == nullptr)
    {
        std::cerr << "the init of MYSQL failed" << std::endl;
        return 1;
    }

    std::cout << "the init of MYSQL sucessful" << std::endl;

    sql = mysql_real_connect(sql,host.c_str(),user.c_str(),password.c_str(),db.c_str(),port,nullptr,0);

    if(sql == nullptr)
    {
        std::cerr << "the connect of MYSQL failed" << std::endl;
        return 1;
    }

    mysql_set_character_set(sql,"utf8");

    //const std::string task="insert into account (name,salary)values('孙权',8500.00)"; 
    const std::string task="delete from account where id = 4"; 
    int n = mysql_query(sql,task.c_str());

    if(n != 0)
        std::cerr << "warning, the sql of" << task << "execute failed" << std::endl;


    std::cout << "the connect of MYSQL sucessful" << std::endl;
    
    printf("the mysql client 版本 : %s \n" , mysql_get_client_info());

    mysql_close(sql);
    return 0;
}